﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skywave.Security
{
    public static class RandomGenerator
    {
        public static string CreateRandomString(int length)
        {
            byte[] hashKey = new byte[length];
            System.Security.Cryptography.RandomNumberGenerator.Create().GetBytes(hashKey);
            string key = "";
            byte temp1;
            foreach (byte fe1 in hashKey)
            {
                if (fe1 <= 57) //Number 0-9
                    temp1 = (byte)(48 + (fe1 % 10));
                else //Captial A->Z
                    temp1 = (byte)(65 + (fe1 % 26));
                key += Convert.ToChar(temp1).ToString();
            }
            return key;
        }
    }
}
